#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
int main()
{
  int fd = open("log.txt",O_CREAT|O_WRONLY|O_TRUNC,0666);
  dup2(fd,1);

  printf("hello printf\n");
  fprintf(stdout,"hello fprintf\n");
  const char* s = "hello fwrite\n";
  fwrite(s,12,1,stdout);
  write(1,"hello write\n",12);
  //close(fd);
  fflush(stdout);

  close(1);
  return 0;
}
